Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
Why are some links ignored / not captured / seen in iframe.getElementsByTagName("a")?

I'm using the following code to get all links in a webpage, even in its iframes:

function GetTheLinks()
{
    var linksArray = [];
    var links = document.getElementsByTagName("a");
    var iLinksCount = links.length;
    for (var i = 0; i < iLinksCount; i++)
    {
        var link = links[i];
        linksArray.push(link.innerHTML);
        linksArray.push(link.innerText);
        linksArray.push(link.href);
    }
    var frames = document.getElementsByTagName("iframe");
    var iFramesCount = frames.length;
    for (var f = 0; f < iFramesCount; f++)
    {
        var doc = frames[f].contentDocument;
        if (doc)
        {
             links = doc.getElementsByTagName("a");
             alert(links.length + " links in frame " + f);
             var iLinksCount = links.length;
             for (var i = 0; i < iLinksCount; i++)
             {
                 var link = links[i];
                 linksArray.push(link.innerHTML);
                 linksArray.push(link.innerText);
                 linksArray.push(link.href);
             }
         }
         else
         {
             alert("Error!");
         }
    }
    return linksArray;
}

I am confronted with an URL where my code does not catch a certain link. The URL is this one.

The link that I want to catch is this one:

enter image description here

Using Chrome's dev tools, I can see that it is contained in a frame.

What am I doing wrong in my code so that it doesn't catch this link?

Thank you!

There is its code:

<a href="https://premium.zeit.de/bestellung/1932788?angebot=https%3A%2F%2Fpremium.zeit.de%2Fbestellung%2F1932788&amp;entry_service=pur&amp;url=https%3A%2F%2Fmeine.zeit.de%2Fbestellung_abschliessen%3Furl%3Dhttps%253A%252F%252Fwww.zeit.de%252Findex" class="option__button option__button--pur js-forward-link-purabo" data-encode-level="1" data-ct-label="purabo_button">
                                    <span class="visually-hidden">zeit.de Pur: </span>Jetzt abonnieren
                                </a>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!